package cmd

import (
	"fmt"
	"xcloud-oauth2-server/config"
	"xcloud-oauth2-server/database"

	"gorm.io/gorm"
)

//initConfigDB loads the configuration and connects to the database
func initConfigDB(configFile string) (*config.Config, *gorm.DB, error) {
	//config
	cfg := config.NewConfig(configFile)

	//database
	fmt.Println("initConfigDB: ", cfg)
	db, err := database.NewDatabase(cfg)
	if err != nil {
		return nil, nil, err
	}
	return cfg, db, nil
}
